package org.jtzc.springaimcpservermvc.config;

import org.jtzc.springaimcpservermvc.FileSystemService;
import org.jtzc.springaimcpservermvc.ImageSearchTool;
import org.jtzc.springaimcpservermvc.OpenMeteoService;
import org.jtzc.springaimcpservermvc.service.DateTimeService;
import org.springframework.ai.tool.ToolCallback;
import org.springframework.ai.tool.ToolCallbackProvider;
import org.springframework.ai.tool.function.FunctionToolCallback;
import org.springframework.ai.tool.method.MethodToolCallbackProvider;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class Config {



    /**
     * 提供天气相关的2个tools
     */
    @Bean
    public ToolCallbackProvider weatherTools2(OpenMeteoService openMeteoService) {
        return MethodToolCallbackProvider.builder()
                .toolObjects(openMeteoService)
                .build();
    }
    /**
     * 配置暴露时间相关
     */
    @Bean
    public ToolCallbackProvider dateTimeTools(DateTimeService dateTimeService) {
        return MethodToolCallbackProvider.builder().toolObjects(dateTimeService).build();
    }
    /*
     * 文件相关
     */
    @Bean
    public ToolCallbackProvider file(FileSystemService fileSystemService) {
        return MethodToolCallbackProvider.builder()
                .toolObjects(fileSystemService)
                .build();
    }

    public record TextInput(String input) {
    }

    /**
     * 将输入字母转为大写的 MCP Tools
     */
    @Bean
    public ToolCallback toUpperCase() {
        return FunctionToolCallback.builder("toUpperCase", (TextInput input) -> input.input().toUpperCase())
                .inputType(TextInput.class)
                .description("Put the text to upper case")
                .build();
    }
    /**
     * 图片检索的
     */

    @Bean
    public ToolCallbackProvider imageSearchTools(ImageSearchTool imageSearchTool) {
        return MethodToolCallbackProvider.builder()
                .toolObjects(imageSearchTool)
                .build();
    }
}
